<template>
	<view class="content">
		<!-- 导航区域 -->
		<scroll-view class="scroll-view_H" scroll-x="true" scroll-left="0" enable-flex="true">
			<view :class="['scroll-view-item_H',currentTab==index?'active':'']" v-for="(item,index) in navbar" :key='index' @click="tabClick(index)">{{item}}</view>
		</scroll-view>
		<!-- 内容区域 -->
		 <swiper class="swiper" :current="currentTab" @change="swiperTab" :style="{height:swiperHeight+'px'}" >
			<swiper-item>
				<view class="swiper-item">
					<ShiCi></ShiCi>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">
					<XiaoShuo></XiaoShuo>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import ShiCi from '@/pages/shici/ShiCi.vue'
	import XiaoShuo from '@/pages/xiaoshuo/XiaoShuo.vue'
	export default {
		components:{
			ShiCi,
			XiaoShuo
		},
		data() {
			return {
				 navbar: ['古代诗词', '网络小说'],//导航栏类目
				 currentTab: 0,//当前选中的导航类目
				 swiperHeight:0//动态给定swiper的高度
			}
		},
		onLoad(option) {
			this.swiperHeight = uni.getSystemInfoSync().windowHeight-25;
			console.log(this.swiperHeight);
		},
		methods: {
		  tabClick(index){
			  this.currentTab=index
		  },
		  swiperTab(e) {
			this.currentTab = e.detail.current; //获取索引
			console.log("this.currentTab",this.currentTab)
		  }
		}
	}
</script>

<style lang="less" scoped>
.content{
	width: 100%;
	/deep/ .scroll-view_H .uni-scroll-view-content{
		width: 100%;
		height: 60rpx;
		text-align: center;
		line-height: 60rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		flex-wrap: nowrap;
		overflow: hidden;
		.scroll-view-item_H{
			flex-shrink: 0;
			flex: 1;
			color: #000000;
			font-size: 30rpx;
			font-size: bold;
			background-color: #eef2f2;
			letter-spacing: .1em;
			text-shadow: 0px 1px 2px #eef2f2;
		}
		.active{
			font-size: 32rpx;
			color: #55aaff;
		}
	}
	.swiper-item{
		height: 100%;
	}
}
</style>
